<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script>
        var app = parent.app;
        var context = parent.context;
    </script>
    <link href="/assets/js/workflow/css/designer.css" rel="stylesheet"/>
    <link href="/assets/js/workflow/css/ControlStyle.css" rel="stylesheet"/>
    <link href="/assets/js/workflow/css/ToolBarstyle.css" rel="stylesheet"/>
    <link href="/assets/js/workflow/css/propertystyle.css" rel="stylesheet"/>


    <link href="/assets/js/ztree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
    <link href="/assets/js/listnav/ihwy-2012.css" rel="stylesheet"/>
    <link href="/assets/js/listnav/jquery.listnav-2.1.css" rel="stylesheet"/>
    <link href="/assets/js/listnav/reset-min.css" rel="stylesheet"/>
    <script src="/assets/js/jquery.min.js" type="text/javascript"></script>
    <script src="/assets/js/jquery.cookie.js"></script>
    <script src="/assets/js/jquery-1.10.2.plugin.js"></script>


    <script src="/assets/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/assets/js/workflow/js/designer/config/TemplateStatus.js"></script>
    <script src="/assets/js/workflow/js/designer/code/arrayhelper.js"></script>
    <script src="/assets/js/jquery.base64.js"></script>
    <script src="/assets/js/ztree/jquery.ztree.all-3.5.js"></script>
    <script src="/assets/js/listnav/jquery.idTabs.min.js"></script>
    <script src="/assets/js/listnav/jquery.listnav-2.1.js"></script>
    <script src="/assets/js/layer/layer.js"></script>

    <script type="text/javascript">
        (function () {

            var jss = ['/assets/js/workflow/js/designer/code/OrgHelper.js',
                '/assets/js/workflow/js/designer/activity/BaseProperty.js',
                '/assets/js/workflow/js/designer/activity/UserProperty.js',
                '/assets/js/workflow/js/designer/activity/ReturnProperty.js',
                '/assets/js/workflow/js/designer/activity/ReminderProperty.js',
                '/assets/js/workflow/js/designer/config/PropertyConfig.js',
                '/assets/js/workflow/js/designer/config/styledefine.js',
                '/assets/js/workflow/js/designer/config/ToolBarConfig.js',
                '/assets/js/workflow/js/designer/code/CanvasHelper.js',
                '/assets/js/workflow/js/designer/code/mathhelper.js',
                '/assets/js/workflow/js/designer/code/activityhelper.js',
                '/assets/js/workflow/js/designer/code/MouseOperation.js',
                '/assets/js/workflow/js/designer/code/Point.js',
                '/assets/js/workflow/js/designer/controls/Activity.js',
                '/assets/js/workflow/js/designer/controls/Arrow.js',
                '/assets/js/workflow/js/designer/controls/Rule.js',
                '/assets/js/workflow/js/designer/code/sqlhelper.js',
                '/assets/js/workflow/js/designer/rule/ruleProperty.js',
                '/assets/js/workflow/js/designer/code/Guid.js',
                '/assets/js/workflow/js/designer/config/activitytype.js',
                '/assets/js/workflow/js/designer/config/Command.js'
            ];
            for (n = 0; n < jss.length; n++) {
                document.write('<script src="' + jss[n] + '?license=' + new Date().getTime() + '"><' + "/" + 'script>');
            }

        })();
    </script>

</head>
<body>


<div id="divBody">
    <div class="toolbar" id="divTools">
        <div>
            <div id="toolBar" style="">
            </div>
        </div>
    </div>
    <div class="workspace" style="overflow: auto;">
        <div id="divWorkspace">
            <!--<div id="divTemplateName" style="width: auto; position:fixed; top:0px;"></div>-->
            <canvas id="myCanvas" style="position: absolute; top: 0px; left: 0px; z-index: 100;"></canvas>
        </div>
    </div>


</div>
<div id="root" class="messagebox" style="display: none; width: 690px;">
    <div id="divProptitle" class="messageboxTitle">
        <div style="margin-left: 15px;">
            属性设置
        </div>
    </div>
    <div id="divActivityProp" class="messageboxContent">
    </div>
    <div class="OKCancelButtonContainer">
        <input id="btnActivityPropOK" type="button" value="确定" class="OKButton"/>
        <input id="btnActivityPropCancel" type="button" value="取消" class="CancelButton"/>
    </div>
</div>
<div id="divRuleProperty" class="messagebox" style="display: none; width: 690px;">
    <div id="divRulePropertyTitle" class="messageboxTitle">
        <div style="margin-left: 15px;">
            属性设置
        </div>
    </div>
    <div id="divRulePropertyContainer" class="messageboxContent">
    </div>
    <div class="OKCancelButtonContainer">
        <input id="btnRulePropertyOK" type="button" value="确定" class="OKButton"/>
        <input id="btnRulePropertyCancel" type="button" value="取消" class="CancelButton"/>
    </div>
</div>
<div id="divOrg" class="messagebox" style="display: none; width: 360px; height: 420px;">
    <div id="divorgTitle" class="messageboxTitle">
        <div style="margin-left: 15px;">
            组织机构
        </div>
    </div>

    <div style="width: 350px; height: 355px; overflow-y: auto" class="messageboxContent">
        <div id="divSearchOrg"
             style="width: auto; font-size: 12px; margin-left: 15px; margin-top: 5px; text-align: left;">
            机构名称：<input type="text" id="txtOrg"/>
            <img src="../../Images/search.png" id="btnSearchOrg"
                 style="width: 18px; margin-right: 5px; margin-top: 2px; cursor: pointer;" title="搜索" alt="搜索"/>
            <img src="../../Images/refresh.png" id="btnRefreshOrg"
                 style="width: 18px; margin-right: 5px; margin-top: 2px; cursor: pointer;" title="刷新" alt="刷新"/>
        </div>
        <ul id="treeOrg" class="ztree" style="width: auto;"></ul>
    </div>
    <div class="OKCancelButtonContainer">
        <!--    <a href="#" id="btnCreateOK">确定</a>-->

        <input id="btnCreateOK" type="button" value="确定" class="OKButton"/>
        <input id="btnCreateCancel" type="button" value="取消" class="CancelButton"/>
    </div>
</div>
<div id="divSave" class="messagebox" style="display: none; width: 650px; height: 300px;">
    <div id="divSaveTitle" class="messageboxTitle">
        <div style="margin-left: 15px;">
            保存
        </div>
    </div>
    <div style="height: 240px; margin-top: 2px;" class="messageboxContent">
        <div class="Prop">
            模版类型：<select id="selectPackage"></select>
        </div>
        <div class='Prop'>
            模版名称：<input id='txtTEMPLATE_NAME' type="text"/>
        </div>
        <div class='Prop'>
            图例：<input id='txtImg' type="text"/>
        </div>
        <div class='Long'>
            描述：<textarea id='txtDESCRIPTION'></textarea>
        </div>
    </div>
    <div class="OKCancelButtonContainer">
        <div style="width: auto;">
            <input id="btnEdit" type="button" value="修改当前版本" class="OKButton"/>
            <input id="btnNewVersion" type="button" value="发布新版本" class="OKButton"/>
            <input id="btnSaveOK" type="button" value="全新发布" class="OKButton"/>
            <input id="btnSaveCancel" type="button" value="取消" class="CancelButton"/>
        </div>
    </div>
</div>
<div id="divOpen" class="messagebox" style="display: none; width: 750px; height: 400px;">
    <div id="divOpenTitle" class="messageboxTitle">
        <div style="margin-left: 15px;">
            打开流程
        </div>
    </div>
    <div class="messageboxContent" style="height: 325px; margin-top: 2px; float: left;">
        <div style="width: 280px; float: left; overflow: auto; height: 312px; margin-right: 5px; border: 1px solid #8db3e3;">
            <ul id="ulOpenTempOrg" class="ztree"></ul>
        </div>
        <div style="width: 220px; float: left;">
            <table style="font-size: 12px; width: 100%;">
                <tr>
                    <td style="text-align: right; height: 30px; line-height: 30px; width: 40px;">
                        类型：
                    </td>
                    <td style="height: 30px; line-height: 30px; width: auto">
                        <div style="width: 145px; overflow: hidden;">
                            <select id="selectOpenTemPackage" style="width: 145px;"></select>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="vertical-align: top; width: 40px;">
                        模版：
                    </td>
                    <td style="width: auto;">
                        <div style="overflow: auto; height: 280px; width: 145px; border: 1px solid #8db3e3;">
                            <ul id="selectTemplate"></ul>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        <div style="width: 200px; float: left;">
            <table style="font-size: 12px; width: 100%">
                <tr>
                    <td style="text-align: center; height: 30px; line-height: 30px;">
                        版本
                    </td>

                </tr>
                <tr>
                    <td style="vertical-align: top; width: 40px;">
                        <div style="overflow: auto; height: 280px; border: 1px solid  #8db3e3;">
                            <ul id="ulVersion"></ul>
                        </div>
                    </td>

                </tr>
            </table>
        </div>
    </div>
    <div class="OKCancelButtonContainer">
        <input id="btnOpenOK" type="button" value="确定" class="OKButton"/>
        <input id="btnOpenCancel" type="button" value="取消" class="CancelButton"/>
    </div>
</div>
<div style="display: none;">
    <input type="file" id="import" accept=".template"/>

    <img id="imgSignalUser" src="/assets/js/workflow/images/signaluser.png"/>
    <img id="imgAutoUser" src="/assets/js/workflow/images/autouser.png"/>

    <img id="imgUndoAllow" src="/assets/js/workflow/images/undoallow.png"/>
    <img id="imgUndoNotAllow" src="/assets/js/workflow/images/undonotallow.png"/>

    <img id="imgEditAllow" src="/assets/js/workflow/images/editallow.png"/>
    <img id="imgEditNotAllow" src="/assets/js/workflow/images/editnotallow.png"/>

    <img id="imgSignAllow" src="/assets/js/workflow/images/signallow.png"/>
    <img id="imgSignNotAllow" src="/assets/js/workflow/images/signnotallow.png"/>
</div>
<script>

    //临时存放打开的模版ID
    var openTemplateId;
    //当前流程的机构ID
    var OrgID;

    var zTreeObj;
    var activityHelper;

    //function initialData(actionCode, data) {
    //    var objData = { TokenGuid: GetCookie('TokenGuid'), ActionCode: actionCode, Data: data };
    //    var data = $.toJSON(objData);
    //    return data;
    //}

    //获取 cookie
    function GetCookie(name) {
        var arr;
        arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
        if (arr !== null) {
            return unescape(arr[2]);
        }
        return null;
    }
    var pageParm = parent.pageParm;
    //操作的模版
    var template = pageParm.template ? pageParm.template : {};//pageParm.wfTemplate;

    //模版状态，打开、新建、导入善重
    var templateStatus;
    //toolbar操作是否为双击
    var isDoubleClickCommand;
    //当前操作的活动
    var currentActivity;

    var currentActivityType
    //当前操作的规则
    var currentRule;
    //全部活动
    var activityHelper;
    //var activitys;
    //全部规则
    var rules;

    var handlerActivity;


    //鼠标事件
    var mouseOperation;


    //是否允许移动节点
    var moveActivity;
    //是否允许移动规则点
    var moveRule;

    var divWorkspace;

    var myCanvas;
    var selectedObjects;
    var gcommand = Command.NullOperation;

    var mathHelper;
    var divMask;
    var canvasHelper;

    var HistroyOpertion;

    var NextOpertion;
    var isIe9;

    $(document).ready(function () {

        isIe9 = false;
        try {
            var version = '';
            var str = window.navigator.userAgent.toLowerCase().split(";");
            $.each(str, function (a, mis) {
                if (mis.indexOf('msie') >= 0) {
                    version = mis;
                    return false;
                }
            });

            if (version.length > 0) {
                version = version.replace('msie', '').replace(' ', '');
                isIe9 = parseInt(version) == 9;
            }

        } catch (e) {
            isIe9 = false;
        }

        $("#btnSearchOrg").click(function () {
            OrgHelper.SearchNode($("#txtOrg").val());
        });
        var offset = 0;
        if (navigator.userAgent.indexOf("Firefox") > 0) {

        }
        HistroyOpertion = new Array();
        NextOpertion = new Array();

        SqlHelper.GetAllTemplate({PACKAGE_NAME: '', ORG_ID: ''});
        templateStatus = TemplateStatus.None;
        selectedObjects = new Array();
        divMask = $("#divMask");

        //var height = $.Request.QueryString("height") - 2;
        //$("#divBody").css({ "height": height, "width": $(document).width() - 10, 'margin': '0' });
        //$("#divTools").css({ "height": $(document).height() });
        //$("#toolBar").css({ "height": $(document).height() });
        divWorkspace = $("#divWorkspace");//.css({ "width": $(document).width() - 45, "height": $(document).height() });
        handlerActivity = new Array();
        $('body').bind('contextmenu', function () {
            return false;
        });
        mathHelper = new MathHelper();
        mouseOperation = new MouseOperation();
        moveActivity = false;
        moveRule = false;
        canvasHelper = new CanvasHelper();
        //activitys = new Array();
        rules = new Array();
        var me = this;

        myCanvas = $("#myCanvas");
        var work = $(".workspace");
        StyleDefine.Window.width = work.width() > StyleDefine.Window.width ? work.width() : StyleDefine.Window.width;
        StyleDefine.Window.height = work.height() > StyleDefine.Window.height ? work.height() : StyleDefine.Window.height;
        divWorkspace.css({"width": StyleDefine.Window.width, "height": StyleDefine.Window.height});
        //$("#divWorkspace").css({ "width": StyleDefine.Window.width, "height": StyleDefine.Window.height });
        myCanvas[0].width = StyleDefine.Window.width;
        myCanvas[0].height = StyleDefine.Window.height;

        //初始化Toolbar
        ToolBar.InitialToolBar();
        SqlHelper.GetAllOrg();


        //初始化组织机构


        $("#btnRefreshOrg").click(function () {
            SqlHelper.GetAllOrg();
            OrgHelper.BindOrg(SqlHelper.OrgList);
        });
        if (pageParm.template) {
            if (pageParm.template.id) {
                openTemplateId = pageParm.template.id;
                debugger;
                ToolBar.Wait();
            }
            //新增

        }

    });

</script>
</body>
</html>
